// 读取api.json并
const fs = require("fs");
const allApi = require("../docs/api.json");
const restApi = require("./restName.json");
let apiJass = "";
// {n:'',f:''}
let noBjMap = []

restApi.forEach(r => {
    let d = allApi.find(e => e.nameUS == r);
    if(d){
        // okApi.push(d);
        apiJass += `native ${d.nameUS} takes ${d.args} returns ${d.returns}`
        apiJass += "\n"

        let t = r.substr(-2).trim();
        // console.log("d",t)

        if(t == "BJ"){
            let noBjName = r.replace("BJ","");
            // console.log(noBjName)
            noBjMap.push({n:noBjName,f:r});
            apiJass += `native ${noBjName} takes ${d.args} returns ${d.returns}`
            apiJass += "\n"
        }

    }
   
})

fs.writeFileSync("../jass/rest.j",apiJass);
fs.writeFileSync("noBjMap.json",JSON.stringify(noBjMap));